#ifndef _TRIGGER_H_
#define _TRIGGER_H_
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>
/* typedef -------------------------------------------------------------------*/
struct Trigger
{
	uint32_t 	_timeTriggerStart;
    int 	    id;
    int         _timeoutHold;
    bool 		_isTriggered;
    bool        _hasHoldTimeout;

    struct TriggerDriver
    {
        void        *obj;
        uint32_t    type;
    }driver;
	
    struct TriggerOperation
    {
	    int        	(*read)(void *obj, uint32_t type);				
        uint32_t    (*timer)(void);
    }ops;

    struct TriggerEvent
    {
        void (*trigger)(int id);
	    void (*release)(int id, int duration);
        void (*hold)(int id);	
    }event;
};

/* define --------------------------------------------------------------------*/
/* macro ---------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/
/* function prototypes -------------------------------------------------------*/
void Trigger_Init(struct Trigger *triggerObj, 
                  void      *obj,
                  uint32_t  type, 
                  int       id,
                  int      (*read)(void *io, uint32_t pin),
                  uint32_t  (*timer)(void));

void Trigger_RegisterEventTrig(struct Trigger *trigger, void (*release)(int id));
void Trigger_RegisterEventRelease(struct Trigger *trigger, void (*release)(int id, int duration));
void Trigger_RegisterEventHold(struct Trigger *trigger, void (*hold)(int id), int timeout);

void Trigger_Check(struct Trigger *trigger);
void Trigger_Process(struct Trigger *trigger);

 bool Trigger_IsTriggering(struct Trigger *triggerObj);
/* functions -----------------------------------------------------------------*/
#endif
